const verifyQueryParams = async (ctx, next) => {
  const requsetObj = {};
  if (ctx.request.body) {
    const { page, size, tagName } = ctx.request.body;
    if (tagName) {
      requsetObj.tagName = tagName;
    }
    if (page) {
      requsetObj.page = page;
    } else {
      requsetObj.page = 1;
    }
    if (size) {
      requsetObj.size = size;
    } else {
      requsetObj.size = 10;
    }
  } else {
    requsetObj.page = 1;
    requsetObj.size = 10;
  }
  ctx.request.body = requsetObj;

  await next();
};

module.exports = { verifyQueryParams };
